<template>
  <div class="jft-exam">
    <div class="page-header">
      <h1>{{ $t('exam.jft') }}</h1>
      <p class="subtitle">JFT基础考试培训，为特定技能签证打下坚实基础</p>
    </div>

    <div class="content-wrapper">
      <!-- 考试介绍 -->
      <el-card class="exam-intro">
        <template #header>
          <div class="card-header">
            <span>考试介绍</span>
          </div>
        </template>
        <div class="intro-content">
          <p>JFT基础考试（Japan Foundation Test for Basic Japanese）是日本国际交流基金会主办的日语基础能力测试，是申请特定技能签证的必备条件之一。</p>
          <div class="exam-info">
            <div class="info-item">
              <h4>考试内容</h4>
              <p>主要测试日常生活和工作中使用的基本日语能力</p>
            </div>
            <div class="info-item">
              <h4>考试形式</h4>
              <p>计算机化考试，包含听力、阅读、语法等部分</p>
            </div>
            <div class="info-item">
              <h4>考试时长</h4>
              <p>约60分钟</p>
            </div>
            <div class="info-item">
              <h4>及格分数</h4>
              <p>200分以上（满分400分）</p>
            </div>
          </div>
        </div>
      </el-card>

      <!-- 考试大纲 -->
      <el-card class="exam-syllabus">
        <template #header>
          <div class="card-header">
            <span>考试大纲</span>
          </div>
        </template>
        <el-collapse v-model="activeNames">
          <el-collapse-item title="听力理解" name="1">
            <div class="syllabus-content">
              <h4>听力理解（约20分钟）</h4>
              <ul>
                <li>日常对话理解</li>
                <li>简单指令理解</li>
                <li>基本信息获取</li>
                <li>场景理解</li>
              </ul>
              <div class="example">
                <strong>示例题型：</strong>
                <p>听一段关于餐厅点餐的对话，选择正确的选项。</p>
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item title="阅读理解" name="2">
            <div class="syllabus-content">
              <h4>阅读理解（约25分钟）</h4>
              <ul>
                <li>短文阅读</li>
                <li>图表信息理解</li>
                <li>实用文阅读</li>
                <li>逻辑关系理解</li>
              </ul>
              <div class="example">
                <strong>示例题型：</strong>
                <p>阅读一份工作申请表，回答相关问题。</p>
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item title="语法词汇" name="3">
            <div class="syllabus-content">
              <h4>语法词汇（约15分钟）</h4>
              <ul>
                <li>基础语法结构</li>
                <li>常用词汇</li>
                <li>敬语使用</li>
                <li>表达方式</li>
              </ul>
              <div class="example">
                <strong>示例题型：</strong>
                <p>选择合适的助词或语法形式完成句子。</p>
              </div>
            </div>
          </el-collapse-item>
        </el-collapse>
      </el-card>

      <!-- 学习资料 -->
      <el-card class="study-materials">
        <template #header>
          <div class="card-header">
            <span>学习资料</span>
          </div>
        </template>
        <div class="materials-grid">
          <div v-for="material in materials" :key="material.id" class="material-card">
            <div class="material-icon">
              <el-icon><component :is="material.icon" /></el-icon>
            </div>
            <div class="material-info">
              <h3>{{ material.name }}</h3>
              <p>{{ material.description }}</p>
              <div class="material-meta">
                <span class="type">{{ material.type }}</span>
                <span class="size">{{ material.size }}</span>
              </div>
              <el-button type="primary" @click="downloadMaterial(material.id)">
                下载资料
              </el-button>
            </div>
          </div>
        </div>
      </el-card>

      <!-- 模拟考试 -->
      <el-card class="mock-exam">
        <template #header>
          <div class="card-header">
            <span>模拟考试</span>
          </div>
        </template>
        <div class="mock-exam-content">
          <p>通过模拟考试熟悉真实考试环境，提高考试通过率。</p>
          <div class="mock-exam-options">
            <div class="option-card">
              <h4>基础模拟考试</h4>
              <p>适合初学者，包含基础题型</p>
              <el-button type="primary" @click="startMockExam('basic')">
                开始考试
              </el-button>
            </div>
            <div class="option-card">
              <h4>进阶模拟考试</h4>
              <p>适合有一定基础的学员</p>
              <el-button type="primary" @click="startMockExam('advanced')">
                开始考试
              </el-button>
            </div>
            <div class="option-card">
              <h4>真题模拟</h4>
              <p>基于历年真题的模拟考试</p>
              <el-button type="primary" @click="startMockExam('real')">
                开始考试
              </el-button>
            </div>
          </div>
        </div>
      </el-card>

      <!-- 考试时间表 -->
      <el-card class="exam-schedule">
        <template #header>
          <div class="card-header">
            <span>考试时间表</span>
          </div>
        </template>
        <el-table :data="examSchedule" style="width: 100%">
          <el-table-column prop="date" label="考试日期" width="120" />
          <el-table-column prop="time" label="考试时间" width="100" />
          <el-table-column prop="location" label="考试地点" />
          <el-table-column prop="deadline" label="报名截止" width="120" />
          <el-table-column prop="seats" label="剩余座位" width="100" />
          <el-table-column label="操作" width="100">
            <template #default="scope">
              <el-button 
                type="primary" 
                size="small" 
                @click="bookExam(scope.row)"
                :disabled="scope.row.seats === 0"
              >
                {{ scope.row.seats === 0 ? '已满' : '报名' }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'

export default {
  name: 'JftExam',
  setup() {
    const router = useRouter()
    const activeNames = ref(['1'])

    const materials = ref([
      {
        id: 1,
        name: 'JFT基础词汇手册',
        description: '包含考试必备的基础词汇和常用表达',
        type: 'PDF文档',
        size: '2.5MB',
        icon: 'Document'
      },
      {
        id: 2,
        name: '语法要点总结',
        description: '系统梳理基础语法知识，便于复习',
        type: 'PDF文档',
        size: '1.8MB',
        icon: 'Document'
      },
      {
        id: 3,
        name: '听力练习音频',
        description: '标准日语发音，提高听力理解能力',
        type: '音频文件',
        size: '15MB',
        icon: 'VideoPlay'
      },
      {
        id: 4,
        name: '模拟试题集',
        description: '多套模拟试题，熟悉考试题型',
        type: 'PDF文档',
        size: '3.2MB',
        icon: 'Document'
      }
    ])

    const examSchedule = ref([
      {
        date: '2024-03-20',
        time: '09:00',
        location: '东京JFT考试中心',
        deadline: '2024-02-20',
        seats: 25
      },
      {
        date: '2024-04-15',
        time: '14:00',
        location: '大阪JFT考试中心',
        deadline: '2024-03-15',
        seats: 18
      },
      {
        date: '2024-05-12',
        time: '10:00',
        location: '名古屋JFT考试中心',
        deadline: '2024-04-12',
        seats: 0
      }
    ])

    const downloadMaterial = (materialId) => {
      ElMessage.success('资料下载成功！')
      // 这里可以实现实际的下载逻辑
    }

    const startMockExam = (type) => {
      ElMessage.success(`开始${type === 'basic' ? '基础' : type === 'advanced' ? '进阶' : '真题'}模拟考试！`)
      // 这里可以跳转到模拟考试页面
    }

    const bookExam = (exam) => {
      router.push('/exam-booking')
    }

    return {
      activeNames,
      materials,
      examSchedule,
      downloadMaterial,
      startMockExam,
      bookExam
    }
  }
}
</script>

<style scoped>
.jft-exam {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.page-header {
  text-align: center;
  margin-bottom: 30px;
}

.page-header h1 {
  font-size: 2.5rem;
  color: #303133;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 1.2rem;
  color: #606266;
}

.content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-header {
  font-weight: bold;
  font-size: 1.2rem;
}

.exam-intro .intro-content {
  line-height: 1.6;
}

.exam-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.info-item {
  padding: 20px;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  text-align: center;
}

.info-item h4 {
  color: #409eff;
  margin-bottom: 10px;
}

.info-item p {
  color: #606266;
  margin: 0;
}

.syllabus-content h4 {
  color: #303133;
  margin-bottom: 15px;
}

.syllabus-content ul {
  margin: 15px 0;
  padding-left: 20px;
}

.syllabus-content li {
  margin-bottom: 8px;
  color: #606266;
}

.example {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  margin-top: 15px;
}

.example strong {
  color: #303133;
}

.example p {
  margin: 8px 0 0 0;
  color: #606266;
}

.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.material-card {
  display: flex;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  padding: 20px;
  transition: transform 0.3s ease;
}

.material-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.material-icon {
  margin-right: 15px;
  display: flex;
  align-items: center;
}

.material-icon .el-icon {
  font-size: 2rem;
  color: #409eff;
}

.material-info {
  flex: 1;
}

.material-info h3 {
  margin: 0 0 10px 0;
  color: #303133;
}

.material-info p {
  color: #606266;
  margin-bottom: 15px;
}

.material-meta {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.type, .size {
  background: #f0f2f5;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9rem;
  color: #606266;
}

.mock-exam-content p {
  margin-bottom: 20px;
  color: #606266;
  line-height: 1.6;
}

.mock-exam-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.option-card {
  text-align: center;
  padding: 25px;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  background: #fafafa;
}

.option-card h4 {
  color: #303133;
  margin-bottom: 10px;
}

.option-card p {
  color: #606266;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .jft-exam {
    padding: 15px;
  }
  
  .page-header h1 {
    font-size: 2rem;
  }
  
  .exam-info {
    grid-template-columns: 1fr;
  }
  
  .materials-grid {
    grid-template-columns: 1fr;
  }
  
  .mock-exam-options {
    grid-template-columns: 1fr;
  }
}
</style>
